//
//  main.cpp
//  MATH233_iLab7
//
//  Created by Ronald Ram on 2/24/13.
//  Copyright (c) 2013 Ronald Ram. All rights reserved.
//

#include <iostream>
#include <limits>
#include <math.h>
#include <iomanip>
using namespace std;


void StepOne();
void StepTwo();
void WelcomeMsg();


int main(int argc, const char * argv[])
{
    //local vars
    bool canQuit = false; string shouldQuit = "";
    
    WelcomeMsg();
    
    do
    {
        StepOne();
        StepTwo();
        
        cout << "\nQuit Program Y/N ? ";  cin >> shouldQuit;
        canQuit = (shouldQuit == "Y" || shouldQuit == "y") ? true : false;
        
        if ( canQuit ) cout << "\nThank you - Good Bye!\n" << endl;
    }
    while ( !canQuit );
    
    return 0;
}


void StepOne()
{
    cout << "\n-----------------------------------------" << endl;
    cout << "\t\tStep 1:" << endl;
    cout << "-----------------------------------------" << endl;
    cout << "INT_MIN = " << numeric_limits<int>::min() << endl;
    cout << "INT_MIN SQUARED = " << exp2f(numeric_limits<int>::min()) << endl << endl;
    
    cout << "Squaring powers of 10, storing in INT (32 bit)" << endl;
    cout << "10 SQUARED = " << (int)pow(10, 2) << endl;
    cout << "100 SQUARED = " << (int)pow(100, 2) << endl;
    cout << "1000 SQUARED = " << (int)pow(1000, 2) << endl;
    cout << "10000 SQUARED = " << (int)pow(10000, 2) << endl;
    cout << "100000 SQUARED = " << (int)pow(100000, 2) << endl;
}

void StepTwo()
{
    cout << "\n\n-----------------------------------------" << endl;
    cout << "\t\tStep 2:" << endl;
    cout << "-----------------------------------------" << endl;
    cout << "FLT_MAX = " << numeric_limits<float>::max() << endl;
    cout << "FLT_MAX DOUBLED = " << numeric_limits<float>::max() + numeric_limits<float>::max() << endl << endl;
    
    cout << "FLT_MIN = " << numeric_limits<float>::min() << endl;
    cout << "FLT_MIN Divided by 10= " << numeric_limits<float>::min() / 10 << endl << endl;
    
    cout << "DBL_EPSILON = " << numeric_limits<double>::epsilon() << endl;
    cout << "( 2 + DBL_EPSILON ) + DBL_EPSILON = " << scientific << ( 2 + numeric_limits<double>::epsilon() ) + numeric_limits<double>::epsilon() << endl;
    cout << "2 + ( DBL_EPSILON + DBL_EPSILON ) = " << scientific << 2 + ( numeric_limits<double>::epsilon() + numeric_limits<double>::epsilon() ) << endl << endl;
    
    double tmpDouble = 0.2, tmp=0.00;
    
    for (int i=0; i< 100; ++i) { tmp +=tmpDouble; }
    cout << "0.2 SUMMED 100 TIMES = " << tmp << endl;
    
    tmp=0.00;
    for (int i=0; i< 10000; ++i) { tmp +=tmpDouble; }
    cout << "0.2 SUMMED 10000 TIMES = " << tmp << endl;
}


void WelcomeMsg()
{
    cout << endl;
    cout << "===================================================" << endl;
    cout << "Welcome to the Data Storage Limit Program" << endl;
    cout << "Class Assignment: MATH 233 - iLab 7" << endl;
    cout << "Author: Ronald Ram" << endl;
    cout << "===================================================" << endl << endl;
}

